package common

import (
	"github.com/openzipkin/zipkin-go"
	"github.com/openzipkin/zipkin-go/reporter/http"
	"time"
)

// NewZipkin new zipkin.
func NewZipkin(appid string, ip string) (*zipkin.Tracer, error) {
	reporter := http.NewReporter(ZipkinApi,
		http.Timeout(5*time.Second), // 2s
		http.BatchSize(100))

	// new endpoint
	endpoint, err := zipkin.NewEndpoint(appid, ip)
	if err != nil {
		return nil, err
	}

	return zipkin.NewTracer(reporter, zipkin.WithLocalEndpoint(endpoint))
}
